home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Initialize.c
-
- Contains: Initialization code for this application
-
- Written by: Chris White, Developer Technical Support
-
- Copyright: © 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- 1/22/96 CW First release
-
- */
-
-
- #pragma segment Initialize
-
-
-
- // System includes
- #include <Resources.h>
- #include <Processes.h>
-
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
-
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
-
- #ifndef __TEXTEDIT__
- #include <TextEdit.h>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef __GESTALT__
- #include <Gestalt.h>
- #endif
-
- #ifndef __SEGLOAD__
- #include <SegLoad.h>
- #endif
-
- #ifndef __CODEFRAGMENTS__
- #include <CodeFragments.h>
- #endif
-
- #ifndef __THREADS__
- #include <Threads.h>
- #endif
-
-
-
-
- // Application includes
-
- #ifndef __BAREBONES__
- #include "BareBones.h"
- #endif
-
- #ifndef __PROTOTYPES__
- #include "Prototypes.h"
- #endif
-
-
-
- // static prototypes
- static Boolean CheckConfiguration ( void );
-
-
-
-
- void InitToolbox ( void )
- {
-
- InitGraf ( &qd.thePort );
- InitFonts ( );
- InitWindows ( );
- InitMenus ( );
- TEInit ( );
- InitDialogs ( nil );
- InitCursor ( );
-
- FlushEvents ( everyEvent, 0 );
-
- return;
- }
-
-
-
- void InitApplication ( void )
- {
- SetMenuBar ( GetNewMBar ( kMenuBarID ) );
- AppendResMenu ( GetMenuHandle ( kAppleMenu ), 'DRVR' );
- DrawMenuBar ( );
-
- if ( !CheckConfiguration ( ) )
- {
- AlertUser ( kNeedSystem7, 0, nil );
- ExitToShell ( );
- }
-
- gQuit = false; // Initialize flag that controls main event loop
- gSleepTime = kSleepTime;
-
- InstallAppleEventHandlers ( );
-
- AdjustMenus ( );
-
- // Create any RoutineDescriptors we may need
- gOutlineUserItemUPP = NewUserItemProc ( OutlineUserItem );
-
- return;
- }
-
-
-
- //
- // Verify that we can run on the current configuration
- //
- static Boolean CheckConfiguration ( void )
- {
- SInt32 theResult;
- OSErr theErr;
- Boolean bHasAppleEvents;
-
-
-
- // We require AppleEvent Manager
- theErr = Gestalt ( gestaltAppleEventsAttr, &theResult );
- bHasAppleEvents = (theErr == noErr && (theResult & (1L << gestaltAppleEventsPresent)));
-
- // We would like the Thread Manager
- theErr = Gestalt ( gestaltThreadMgrAttr, &theResult );
- gHasThreadManager = (theErr == noErr && (theResult & (1L << gestaltThreadMgrPresent)));
-
- // It isn't enough to use Gestalt because we may not have successfully linked
- // to the shared library. So, we also need to test one of the symbols from the
- // library against kUnresolvedSymbol to make sure we have a valid connection
- // to it. Things like memory limitations or someone having a library open with
- // write permission could cause it to fail.
-
- #if GENERATINGCFM
- if ( gHasThreadManager )
- gHasThreadManager = (NewThread != (void*) kUnresolvedCFragSymbolAddress);
- #endif
-
-
- return bHasAppleEvents;
- }
-
-
-